package com.fishery.authority.mapper;

import com.fishery.authority.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 711
 * @since 2021-01-13
 */
public interface UserMapper extends BaseMapper<User> {
    /**
     * 修改用户的基地信息
     *
     * @param baseId
     * @param baseIdentity
     * @param userId
     */
    void setBase(@Param("baseId") String baseId, @Param("baseIdentity") Integer baseIdentity, @Param("userId") String userId);

    /**
     * 根据基地id查询用户
     *
     * @param baseId
     * @return
     */
    List<User> getUsersByBaseId(String baseId);

    List<User> findOthersByBaseIdAndUserId(@Param("baseId")String baseId, @Param("userId") String userId);

    void deleteALLById(String userId);

    void addRoleToUser(@Param("userId") String userId, @Param("roleId") String roleId);

    void setBaseNull(String baseId);

    void updateRoleAndUser(@Param("userId")String userId, @Param("roleId")String roleId);

    @Select("SELECT id,is_admin,phone,password,base_id,base_identity,avatar,username,username_status,email FROM t_authority_user WHERE phone = #{phone} AND is_deleted = 0")
    User selectByPhone(@Param("phone") String phone);
}
